blob: ab5754e05d16d70b79cf90437bc999628aa99151 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-am(1)
2=========
3
4NAME
5----
Junio C Hamano7c73c662007-01-19 00:37:506git-am - Apply a series of patches from a mailbox
Junio C Hamano1a4e8412005-12-27 08:17:237
8
9SYNOPSIS
10--------
Junio C Hamano235a91e2006-01-07 01:13:5811[verse]
Junio C Hamano3d1b5a12013-05-17 23:34:0212'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8]
Junio C Hamano9c512872015-08-12 21:59:2513 [--[no-]3way] [--interactive] [--committer-date-is-author-date]
Junio C Hamanofe24db02009-08-22 05:10:4714 [--ignore-date] [--ignore-space-change | --ignore-whitespace]
Junio C Hamanocc0cb312009-01-22 03:38:5015 [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
Junio C Hamano0c1b64e2012-04-20 23:50:4916 [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]
Junio C Hamano3214e5f2014-03-25 19:54:3817 [--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>]
Junio C Hamanod2179ef2010-10-22 04:12:1718 [(<mbox> | <Maildir>)...]
Junio C Hamano35a51552020-03-10 06:08:5819'git am' (--continue | --skip | --abort | --quit | --show-current-patch[=(diff|raw)])
Junio C Hamano1a4e8412005-12-27 08:17:2320
21DESCRIPTION
22-----------
23Splits mail messages in a mailbox into commit log message,
24authorship information and patches, and applies them to the
25current branch.
26
27OPTIONS
28-------
Junio C Hamanod2179ef2010-10-22 04:12:1729(<mbox>|<Maildir>)...::
Junio C Hamano9cb74f22007-02-12 04:15:0530The list of mailbox files to read patches from. If you do not
Junio C Hamano7924d5e2009-03-03 08:28:4831supply this argument, the command reads from the standard input.
32If you supply directories, they will be treated as Maildirs.
Junio C Hamano9cb74f22007-02-12 04:15:0533
Junio C Hamanoeb415992008-06-08 22:49:4734-s::
35--signoff::
Junio C Hamano86f31572009-05-06 07:38:4236Add a `Signed-off-by:` line to the commit message, using
Junio C Hamano1a4e8412005-12-27 08:17:2337the committer identity of yourself.
Junio C Hamano4e6ba272016-01-20 23:23:1938See the signoff option in linkgit:git-commit[1] for more information.
Junio C Hamano1a4e8412005-12-27 08:17:2339
Junio C Hamanoeb415992008-06-08 22:49:4740-k::
41--keep::
Junio C Hamano1aa40d22010-01-21 17:46:4342Pass `-k` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
Junio C Hamano1d3a6c72007-01-09 11:13:4743
Junio C Hamanob5be0522012-01-29 22:20:1944--keep-non-patch::
45Pass `-b` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
46
Junio C Hamano3d1b5a12013-05-17 23:34:0247--[no-]keep-cr::
Junio C Hamanocaa712a2010-03-11 01:17:3548With `--keep-cr`, call 'git mailsplit' (see linkgit:git-mailsplit[1])
49with the same option, to prevent it from stripping CR at the end of
50lines. `am.keepcr` configuration variable can be used to specify the
51default behaviour. `--no-keep-cr` is useful to override `am.keepcr`.
52
Junio C Hamanoc28068f2009-09-08 00:55:2353-c::
54--scissors::
55Remove everything in body before a scissors line (see
Junio C Hamano7f1bc9d2015-03-05 22:38:2656linkgit:git-mailinfo[1]). Can be activated by default using
57the `mailinfo.scissors` configuration variable.
Junio C Hamanoc28068f2009-09-08 00:55:2358
Junio C Hamano01f1fbd2010-03-05 07:36:4159--no-scissors::
Junio C Hamanocf5b7732009-09-11 23:28:3260Ignore scissors lines (see linkgit:git-mailinfo[1]).
61
Junio C Hamano6df93d92014-12-22 22:48:0962-m::
63--message-id::
64Pass the `-m` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]),
65so that the Message-ID header is added to the commit message.
66The `am.messageid` configuration variable can be used to specify
67the default behaviour.
68
69--no-message-id::
70Do not add the Message-ID header to the commit message.
71`no-message-id` is useful to override `am.messageid`.
72
Junio C Hamano2c14c8d2009-07-02 03:17:0073-q::
74--quiet::
75Be quiet. Only print error messages.
76
Junio C Hamanoeb415992008-06-08 22:49:4777-u::
78--utf8::
Junio C Hamano1aa40d22010-01-21 17:46:4379Pass `-u` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
Junio C Hamano1d3a6c72007-01-09 11:13:4780The proposed commit log message taken from the e-mail
Junio C Hamano0430e3a2007-05-15 03:13:1781is re-coded into UTF-8 encoding (configuration variable
Junio C Hamano1d3a6c72007-01-09 11:13:4782`i18n.commitencoding` can be used to specify project's
83preferred encoding if it is not UTF-8).
84+
85This was optional in prior versions of git, but now it is the
Junio C Hamano7924d5e2009-03-03 08:28:4886default. You can use `--no-utf8` to override this.
Junio C Hamano1d3a6c72007-01-09 11:13:4787
88--no-utf8::
Junio C Hamano1aa40d22010-01-21 17:46:4389Pass `-n` flag to 'git mailinfo' (see
Junio C Hamano35738e82008-01-07 07:55:4690linkgit:git-mailinfo[1]).
Junio C Hamano1a4e8412005-12-27 08:17:2391
Junio C Hamanoeb415992008-06-08 22:49:4792-3::
93--3way::
Junio C Hamano9c512872015-08-12 21:59:2594--no-3way::
Junio C Hamano1a4e8412005-12-27 08:17:2395When the patch does not apply cleanly, fall back on
Junio C Hamano7924d5e2009-03-03 08:28:48963-way merge if the patch records the identity of blobs
97it is supposed to apply to and we have those blobs
Junio C Hamano9c512872015-08-12 21:59:2598available locally. `--no-3way` can be used to override
99am.threeWay configuration variable. For more information,
100see am.threeWay in linkgit:git-config[1].
Junio C Hamano0430e3a2007-05-15 03:13:17101
Junio C Hamano6b7d2152019-04-16 12:51:15102--rerere-autoupdate::
103--no-rerere-autoupdate::
104Allow the rerere mechanism to update the index with the
105result of auto-conflict resolution if possible.
106
Junio C Hamanofe24db02009-08-22 05:10:47107--ignore-space-change::
108--ignore-whitespace::
Junio C Hamano0430e3a2007-05-15 03:13:17109--whitespace=<option>::
Junio C Hamanoeb415992008-06-08 22:49:47110-C<n>::
111-p<n>::
Junio C Hamanocc0cb312009-01-22 03:38:50112--directory=<dir>::
Junio C Hamanodac21e72011-08-19 06:50:43113--exclude=<path>::
Junio C Hamano0c1b64e2012-04-20 23:50:49114--include=<path>::
Junio C Hamano22bcc112009-01-24 08:05:18115--reject::
Junio C Hamano1aa40d22010-01-21 17:46:43116These flags are passed to the 'git apply' (see linkgit:git-apply[1])
Junio C Hamano0430e3a2007-05-15 03:13:17117program that applies
118the patch.
119
Junio C Hamano3214e5f2014-03-25 19:54:38120--patch-format::
121By default the command will try to detect the patch format
122automatically. This option allows the user to bypass the automatic
123detection and specify the patch format that the patch(es) should be
Junio C Hamanoc6c919b2016-07-06 21:34:15124interpreted as. Valid formats are mbox, mboxrd,
125stgit, stgit-series and hg.
Junio C Hamano3214e5f2014-03-25 19:54:38126
Junio C Hamanoeb415992008-06-08 22:49:47127-i::
128--interactive::
Junio C Hamano0430e3a2007-05-15 03:13:17129Run interactively.
Junio C Hamano1a4e8412005-12-27 08:17:23130
Junio C Hamanoa3bb6eb2009-02-05 01:26:33131--committer-date-is-author-date::
132By default the command records the date from the e-mail
133message as the commit author date, and uses the time of
134commit creation as the committer date. This allows the
135user to lie about the committer date by using the same
Junio C Hamano86f31572009-05-06 07:38:42136value as the author date.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33137
138--ignore-date::
139By default the command records the date from the e-mail
140message as the commit author date, and uses the time of
141commit creation as the committer date. This allows the
Junio C Hamano86f31572009-05-06 07:38:42142user to lie about the author date by using the same
143value as the committer date.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33144
Junio C Hamano1a4e8412005-12-27 08:17:23145--skip::
146Skip the current patch. This is only meaningful when
147restarting an aborted patch.
148
Junio C Hamano5b3533d2014-02-27 23:07:15149-S[<keyid>]::
150--gpg-sign[=<keyid>]::
Junio C Hamano1eb56092015-10-05 20:39:53151GPG-sign commits. The `keyid` argument is optional and
152defaults to the committer identity; if specified, it must be
153stuck to the option without a space.
Junio C Hamano5b3533d2014-02-27 23:07:15154
Junio C Hamanob2628b12010-02-12 08:08:08155--continue::
Junio C Hamanoeb415992008-06-08 22:49:47156-r::
157--resolved::
Junio C Hamano1a4e8412005-12-27 08:17:23158After a patch failure (e.g. attempting to apply
159conflicting patch), the user has applied it by hand and
160the index file stores the result of the application.
161Make a commit using the authorship and commit log
162extracted from the e-mail message and the current index
163file, and continue.
164
Junio C Hamano0e3cb532007-04-17 08:28:11165--resolvemsg=<msg>::
166When a patch failure occurs, <msg> will be printed
167to the screen before exiting. This overrides the
Junio C Hamanoa1952302013-07-01 21:31:18168standard message informing you to use `--continue`
Junio C Hamano0e3cb532007-04-17 08:28:11169or `--skip` to handle the failure. This is solely
Junio C Hamano1aa40d22010-01-21 17:46:43170for internal use between 'git rebase' and 'git am'.
Junio C Hamano0e3cb532007-04-17 08:28:11171
Junio C Hamano5ba2c222008-07-21 04:33:46172--abort::
173Restore the original branch and abort the patching operation.
174
Junio C Hamano615c3b32018-02-28 23:40:27175--quit::
176Abort the patching operation but keep HEAD and the index
177untouched.
178
Junio C Hamano35a51552020-03-10 06:08:58179--show-current-patch[=(diff|raw)]::
180Show the message at which `git am` has stopped due to
181conflicts. If `raw` is specified, show the raw contents of
182the e-mail message; if `diff`, show the diff portion only.
183Defaults to `raw`.
Junio C Hamano664750f2018-03-06 23:25:44184
Junio C Hamano1a4e8412005-12-27 08:17:23185DISCUSSION
186----------
187
Junio C Hamano35e57552007-03-25 07:54:35188The commit author name is taken from the "From: " line of the
Junio C Hamano86f31572009-05-06 07:38:42189message, and commit author date is taken from the "Date: " line
Junio C Hamano35e57552007-03-25 07:54:35190of the message. The "Subject: " line is used as the title of
191the commit, after stripping common prefix "[PATCH <anything>]".
Junio C Hamano86f31572009-05-06 07:38:42192The "Subject: " line is supposed to concisely describe what the
193commit is about in one line of text.
Junio C Hamano35e57552007-03-25 07:54:35194
Junio C Hamano9d828c92020-01-08 21:18:22195"From: ", "Date: ", and "Subject: " lines starting the body override the
196respective commit author name and title values taken from the headers.
Junio C Hamano35e57552007-03-25 07:54:35197
198The commit message is formed by the title taken from the
199"Subject: ", a blank line and the body of the message up to
Junio C Hamano86f31572009-05-06 07:38:42200where the patch begins. Excess whitespace at the end of each
201line is automatically stripped.
Junio C Hamano35e57552007-03-25 07:54:35202
203The patch is expected to be inline, directly following the
Junio C Hamano7924d5e2009-03-03 08:28:48204message. Any line that is of the form:
Junio C Hamano35e57552007-03-25 07:54:35205
206* three-dashes and end-of-line, or
207* a line that begins with "diff -", or
208* a line that begins with "Index: "
209
210is taken as the beginning of a patch, and the commit log message
211is terminated before the first occurrence of such a line.
212
Junio C Hamano86f31572009-05-06 07:38:42213When initially invoking `git am`, you give it the names of the mailboxes
Junio C Hamano7924d5e2009-03-03 08:28:48214to process. Upon seeing the first patch that does not apply, it
215aborts in the middle. You can recover from this in one of two ways:
Junio C Hamano1a4e8412005-12-27 08:17:23216
Junio C Hamano92d80372016-07-13 22:00:05217. skip the current patch by re-running the command with the `--skip`
Junio C Hamano1a4e8412005-12-27 08:17:23218 option.
219
220. hand resolve the conflict in the working directory, and update
Junio C Hamano7924d5e2009-03-03 08:28:48221 the index file to bring it into a state that the patch should
Junio C Hamano92d80372016-07-13 22:00:05222 have produced. Then run the command with the `--continue` option.
Junio C Hamano1a4e8412005-12-27 08:17:23223
Junio C Hamano78f25df2011-03-23 00:05:35224The command refuses to process new mailboxes until the current
225operation is finished, so if you decide to start over from scratch,
226run `git am --abort` before running the command with mailbox
Junio C Hamano1a4e8412005-12-27 08:17:23227names.
228
Junio C Hamano38ddcce2008-07-15 15:49:03229Before any patches are applied, ORIG_HEAD is set to the tip of the
230current branch. This is useful if you have problems with multiple
231commits, like running 'git am' on the wrong branch or an error in the
232commits that is more easily fixed by changing the mailbox (e.g.
233errors in the "From:" lines).
234
Junio C Hamano81703b22014-03-14 22:00:27235HOOKS
236-----
237This command can run `applypatch-msg`, `pre-applypatch`,
238and `post-applypatch` hooks. See linkgit:githooks[5] for more
239information.
Junio C Hamano1a4e8412005-12-27 08:17:23240
241SEE ALSO
242--------
Junio C Hamano35738e82008-01-07 07:55:46243linkgit:git-apply[1].
Junio C Hamano1a4e8412005-12-27 08:17:23244
Junio C Hamano1a4e8412005-12-27 08:17:23245GIT
246---
Junio C Hamanof7c042d2008-06-06 22:50:53247Part of the linkgit:git[1] suite